package com.fc.authentication.core.spring.config;

import org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import net.sf.oval.guard.GuardInterceptor;

/**
 * Created by Sunny on 2018/6/20.
 */
@Configuration
public class CommonConfig {

    @Bean("ovalGuardInterceptor")
    public GuardInterceptor guardInterceptor(){
        GuardInterceptor guardInterceptor = new GuardInterceptor();
        return guardInterceptor;
    }

    @Bean
    public BeanNameAutoProxyCreator guardAutoProxy(){
        BeanNameAutoProxyCreator guardAutoProxy = new BeanNameAutoProxyCreator();
        guardAutoProxy.setProxyTargetClass(true);
        guardAutoProxy.setBeanNames("*Resource");
        guardAutoProxy.setInterceptorNames("ovalGuardInterceptor");

        return guardAutoProxy;
    }
}
